package com.mrx.compose.test.ui.chat

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.awt.ComposeWindow
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import com.mrx.compose.test.config.WindowConfig
import com.mrx.compose.test.ui.BaseWindow

object ChatWindow : BaseWindow() {

    override val title: String = "ChatWindow"

    override val size: DpSize = DpSize(800.dp, 600.dp)

    @Composable
    override fun app(window: ComposeWindow) {
        repeat(100) {
            userCard("admin $it")
        }
    }

    @Composable
    fun avatar(painter: Painter) = Image(painter, "avatar image", modifier = Modifier.size(32.dp))

    @Composable
    fun userCard(userName: String) {
        Column(modifier = Modifier.padding(bottom = 10.dp).maxWidthBroder()) {
            Row(verticalAlignment = Alignment.CenterVertically) {
                avatar(WindowConfig.image)
                Text(userName, modifier = Modifier.padding(start = 10.dp))
            }
        }
    }
}